# The guess API is already defined for you.
# @param num, your guess
# @return -1 if my number is lower, 1 if my number is higher, otherwise return 0
pick = 7
def guess(num: int) -> int:
    if num == pick:
        return 0
    if num<pick:
        return 1
    else:
        return -1

class Solution:
    def guessNumber(self, n: int) -> int:
        low = 1
        high = n
        while low<=high:
            mid = low + (high - low) // 2
            if guess(mid) == 0:
                return mid
            elif guess(mid)>0:
                low = mid + 1
            else:
                high = mid - 1
        return mid



if __name__ == '__main__':
    so = Solution()
    n = 10
    pick = 6
    r = so.guessNumber(n)
    print(r)
